
package tilefoneia;
import java.util.ArrayList;

public class Syndesi {
    
    private Syndromitis syndromitis;
    private String arithmosTilefonou;
    private String hmeromSyndesis;
    private String hmeromDiakopis;
    private int katastasi;
    private ArrayList <Programma> progs;
    
    public Syndesi(Syndromitis syndromitis, String arithmosTilefonou, Programma prog1, Programma prog2, String hmeromSyndesis) {
        this.syndromitis = syndromitis;
        progs = new ArrayList(2);
        this.arithmosTilefonou = arithmosTilefonou;
        this.hmeromSyndesis = hmeromSyndesis;
        this.hmeromDiakopis = "";
        progs.add(prog1);
        progs.add(prog2);
    }

    public Syndesi(Syndromitis syndromitis, String arithmosTilefonou, Programma prog1, String hmeromSyndesis) {
        this.syndromitis = syndromitis;
        progs = new ArrayList(1);
        this.arithmosTilefonou = arithmosTilefonou;
        this.hmeromSyndesis = hmeromSyndesis;
        progs.add(prog1);
    }
    
    public void addKlisi(String hmerominia, String ora_lepta, int diarkeia) {
        for (Programma progr : progs) 
            if (progr instanceof Omilias) {
                Omilias progOmilias = (Omilias)progr;
                progOmilias.addKlisi(hmerominia, ora_lepta, diarkeia);
            }
    }
    
    public String getArithmoTilefonou(){
        return arithmosTilefonou;
    }
    
    public Omilias getProgrOmilias() {
        for (Programma progOmilias : progs) 
            if (progOmilias instanceof Omilias) 
                return (Omilias)progOmilias;
        return null;
    }
    
    public String toString() {
        return ("Σύνδεση: " + arithmosTilefonou + " Συνδρομητής: " + syndromitis.getOnoma() + "  Ημερομηνία σύνδεσης: " + hmeromSyndesis);
    }
}
